package homework;


import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Work03 {
    //案例：
    //
    //	把如下这些数据存放到一个data.txt文件中，并且再次读取显示
    //int a = 10;
    //char c = 'a';
    //double d = 2.5;
    //boolean b = true;
    //String str = "软帝联合";
    public static void main(String[] args) throws IOException {
        //创建流写入
        FileWriter fw = new FileWriter("day09-code/src/file/data.txt");
        fw.write("int a = 10;\n");
        fw.write("char c = 'a';\n");
        fw.write("double d = 2.5;\n");
        fw.write("boolean b = true;\n");
        fw.write("String str = \"软帝联合\";\n");
        //关闭流
        fw.close();
        //创建读取流
        FileReader fr = new FileReader("day09-code/src/file/data.txt");
        int len;
        while ((len = fr.read()) != -1){
            System.out.print((char)len);
        }
        fr.close();
    }
}
